<!DOCTYPE html>

<html>

  <head>
    <title>Ch. 12 - Drake</title>
    <meta name="Ch. 12 - Drake" content="text/html; charset=utf-8;" />
    <link rel="canonical" href="http://manipulation.csail.mit.edu/drake.html" />

    <script src="https://hypothes.is/embed.js" async></script>
    <script type="text/javascript" src="chapters.js"></script>
    <script type="text/javascript" src="htmlbook/book.js"></script>

    <script src="htmlbook/mathjax-config.js" defer></script> 
    <script type="text/javascript" id="MathJax-script" defer
      src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-chtml.js">
    </script>
    <script>window.MathJax || document.write('<script type="text/javascript" src="htmlbook/MathJax/es5/tex-chtml.js" defer><\/script>')</script>

    <link rel="stylesheet" href="htmlbook/highlight/styles/default.css">
    <script src="htmlbook/highlight/highlight.pack.js"></script> <!-- http://highlightjs.readthedocs.io/en/latest/css-classes-reference.html#language-names-and-aliases -->
    <script>hljs.initHighlightingOnLoad();</script>

    <link rel="stylesheet" type="text/css" href="htmlbook/book.css" />
  </head>

<body onload="loadChapter('manipulation');">

<div data-type="titlepage" pdf="no">
  <header>
    <h1><a href="index.html" style="text-decoration:none;">Robotic Manipulation</a></h1>
    <p data-type="subtitle">Perception, Planning, and Control</p> 
    <p style="font-size: 18px;"><a href="http://people.csail.mit.edu/russt/">Russ Tedrake</a></p>
    <p style="font-size: 14px; text-align: right;"> 
      &copy; Russ Tedrake, 2020-2023<br/>
      Last modified <span id="last_modified"></span>.</br>
      <script>
      var d = new Date(document.lastModified);
      document.getElementById("last_modified").innerHTML = d.getFullYear() + "-" + (d.getMonth()+1) + "-" + d.getDate();</script>
      <a href="misc.html">How to cite these notes, use annotations, and give feedback.</a><br/>
    </p>
  </header>
</div>

<p pdf="no"><b>Note:</b> These are working notes used for <a
href="http://manipulation.csail.mit.edu/Fall2023/">a course being taught
at MIT</a>. They will be updated throughout the Fall 2023 semester.  <!-- <a 
href="https://www.youtube.com/channel/UChfUOAhz7ynELF-s_1LPpWg">Lecture  videos are available on YouTube</a>.--></p> 

<table style="width:100%;" pdf="no"><tr style="width:100%">
  <td style="width:33%;text-align:left;"><a class="previous_chapter" href=rl.html>Previous Chapter</a></td>
  <td style="width:33%;text-align:center;"><a href=index.html>Table of contents</a></td>
  <td style="width:33%;text-align:right;"><a class="next_chapter" href=environments.html>Next Chapter</a></td>
</tr></table>

<script type="text/javascript">document.write(notebook_header('drake'))
</script>
<!-- EVERYTHING ABOVE THIS LINE IS OVERWRITTEN BY THE INSTALL SCRIPT -->
<chapter class="appendix" style="counter-reset: chapter 0"><h1>Drake</h1>

  <p><drake></drake> is the main software toolbox that we use for this text,
  which in fact originated in a large part due to the MIT <a
  href="https://underactuated.mit.edu">Underactuated Robotics</a> course. The
  <drake></drake> website is the main source for information and documentation.
  The goal of this chapter is to provide any additional information that can
  help you get up and running with the examples and exercises provided in these
  notes.</p>

  <section><h1>Pydrake</h1>

    <p><drake></drake> is primarily a C++ library, with rigorous coding
    standards and a maturity level intended to support even professional
    applications in industry.  In order to provide a gentler introduction, and
    to facilitate rapid prototyping, I've written these notes exclusively in
    python, using Drake's python bindings (pydrake).  These bindings are less
    mature than the C++ backend; your feedback (and even contributions) are very
    welcome. It is still improving rapidly.</p>

    <p>In particular, while the C++ API documentation is excellent, the autogenerated python docs are still a work in progress.  I currently recommend using the <a href="https://drake.mit.edu/doxygen_cxx/">C++ documentation</a> to find what you need, then checking the <a href="https://drake.mit.edu/pydrake/">Python documentation</a> only if you need to understand how the class or method is spelled in pydrake.</p>

    <p>There are also a number of <a href="https://github.com/RobotLocomotion/drake/tree/master/tutorials">tutorials</a> in <drake></drake> that can help you get started.</p>

  </section>

  <section id="notebooks"><h1>Online Jupyter Notebooks</h1>

    <p>I will provide nearly all examples and exercises in the form of a <a
    href="http://jupyter.org/">Jupyter Notebook</a> so that we can leverage the
    fantastic and relatively recent availability of (free) cloud resources.</p>

    <subsection><h1>Running on Deepnote</h1>
    
    <p>We'll use Deepnote as the primary platform for the course.  After
    following any of the links from the chapters, you should:
    </p>

      <ol>
      <li>Log in (the free account will be sufficient for this class)</li>
      <li>"Duplicate" the document.  Icon is in the top right next to
      Login.</li> 
      <li>Run all of the cells (can use the "Run notebook" icon just above this
      cell)</li>
      <li>Many of the notebooks use <a
      href="https://github.com/rdeits/meshcat">MeshCat</a> for interactive
      visualizations.  Click on the url printed just below "StartMeshcat"
      (often the second code cell of the notebook) to see the MeshCat
      window.</li>
      </ol>
    </subsection>

    <subsection><h1>Running on Google Colab</h1>

      <p>As of now, Drake no longer supports Google Colab, which is stuck on
      Ubuntu 18.04 and Python 3.7.  We will try to support it again if/when
      they upgrade.</p>

      <!--
      <p>Although I believe that Deepnote provides a better and more reliable
      experience overall, there are a few reasons to be able to also run the
      notebooks on Google Colab.  It has very convenient connections to Google
      Drive, and also substantial free GPU resources (useful for training big
      neural nets).</p>
      
      <p>To run any notebook on Colab, just open the file in colab using a
      direct link to the relevant notebook, e.g.: <a
      href="https://colab.research.google.com/github/RussTedrake/manipulation/blob/master/intro.ipynb">https://colab.research.google.com/github/RussTedrake/manipulation/blob/master/intro.ipynb</a>.
      Then you must manually add the following line in a code cell at the top
      of the notebook (and run it once)
        <pre><code class="python">!pip install manipulation</code></pre>
      </p>

      <p>Note: Drake's pip wheels are only updated at each (monthly) release.
      During the semester, I will often use bleeding-edge features from Drake;
      they will be available in Deepnote immediately, but will only work in
      Colab after the next monthly release.</p>
      -->
    </subsection>

    <subsection><h1>Enabling licensed solvers</h1>

      <p>You can enabled more powerful solvers for
      <code>MathematicalProgram</code> if you have a license (most are free for
      academics).  Please see <script>document.write(notebook_link('tutorials', d=drake_deepnote, link_text='this tutorial notebook', notebook='licensed_solvers_deepnote', workspace_id=drake_workspace_id))</script>
      for instructions.</p>

    </subsection>

  </section>

  <section><h1>Running on your own machine</h1>

    <p>As you get more advanced, you will likely want to run (and extend) these examples on your own machine. On <a href="https://drake.mit.edu/installation.html">platforms/configurations that Drake supports</a> (the latest two releases of Mac and Ubuntu using the system default python versions). The simplest installation is via <code>pip</code>; I would strongly recommend using a virtual environment:
    <div style="background:#f0f0f0;">
      <div style="display:flex; justify-content:flex-end;"><button style="padding:10; background-color: transparent; border:0" onclick="copy_code_to_clipboard(this)"><svg stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" stroke-linecap="round" stroke-linejoin="round" class="icon-sm" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"></path><rect x="8" y="2" width="8" height="4" rx="1" ry="1"></rect></svg>Copy code</button></div>
      <pre><code class="bash">python3 -m venv venv
source venv/bin/activate
pip3 install manipulation --extra-index-url https://drake-packages.csail.mit.edu/whl/nightly/       
      </code></pre>
    </div>
    </p>
            
    <p></p>The <drake></drake> website also has a number of alternative <a
    href="https://drake.mit.edu/installation.html">installation options</a>,
    including precompiled binaries and Docker instances.  If you build from
    source (awesome!), then make sure you also build the python bindings.
    Finally, make sure you have the Drake installation in your
    <code>PYTHONPATH</code>.</p>

    <p>You'll likely want to start from the manipulation root directory.  Then launch your notebook with:</p>

    <div style="background:#f0f0f0;">
      <div style="display:flex; justify-content:flex-end;"><button style="padding:10; background-color: transparent; border:0" onclick="copy_code_to_clipboard(this)"><svg stroke="currentColor" fill="none" stroke-width="2" viewBox="0 0 24 24" stroke-linecap="round" stroke-linejoin="round" class="icon-sm" height="1em" width="1em" xmlns="http://www.w3.org/2000/svg"><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2"></path><rect x="8" y="2" width="8" height="4" rx="1" ry="1"></rect></svg>Copy code</button></div>
      <pre><code class="bash">jupyter notebook</code></pre>
    </div>

    <p>The examples for each chapter that has them will be in a .ipynb file
    right alongside the chapter's html file, and the notebook exercises are
    all located in the <code>exercises</code> subdirectories.

  </section>

  <section><h1>Getting help</h1>

    <p>If you have trouble with <drake></drake>, please follow the advice <a href="https://drake.mit.edu/getting_help.html">here</a>.  If you have trouble with the manipulation repo, you can check for known issues (and potentially file a new one) <a href="https://github.com/RussTedrake/manipulation/issues">here</a>.</p>

  </section>

    <div style="height:30px"></div>

</chapter>
<!-- EVERYTHING BELOW THIS LINE IS OVERWRITTEN BY THE INSTALL SCRIPT -->

<div id="references"></div>

<table style="width:100%;" pdf="no"><tr style="width:100%">
  <td style="width:33%;text-align:left;"><a class="previous_chapter" href=rl.html>Previous Chapter</a></td>
  <td style="width:33%;text-align:center;"><a href=index.html>Table of contents</a></td>
  <td style="width:33%;text-align:right;"><a class="next_chapter" href=environments.html>Next Chapter</a></td>
</tr></table>

<div id="footer" pdf="no">
  <hr>
  <table style="width:100%;">
    <tr><td><a href="https://accessibility.mit.edu/">Accessibility</a></td><td style="text-align:right">&copy; Russ
      Tedrake, 2023</td></tr>
  </table>
</div>


</body>
</html>
